var obj=[
{
    score:85,
    seq:99999,
    level:"NOTDEF"
},
{
    score:98,
    seq:99999,
    level:"NOTDEF"
},
{
    score:98,
    seq:99999,
    level:"NOTDEF"
},
{
    score:90,
    seq:99999,
    level:"NOTDEF"
},
{
    score:80,
    seq:99999,
    level:"NOTDEF"
},
{
    score:93,
    seq:99999,
    level:"NOTDEF"
}];

function findMaxIndex(obj)
{
    var length=obj.length;
    var minScore=0;
    var index=99999;
    var i=0;
    for(i=0;i<length;i++)
    {
        if(obj[i].score>minScore && obj[i].seq==99999)
        {
            index=i;
            minScore=obj[i].score;
        }        
    }
    return index;
}
function SeqToLevel(seq,num)
{
    var a,b,c;
    switch (num)
    {
        case 2:a=1;b=0;c=1;break;
        case 3:a=1;b=1;c=1;break;
        case 4:a=1;b=1;c=2;break;
        case 5:a=1;b=2;c=2;break;
        case 6:a=1;b=2;c=3;break;
        case 7:a=1;b=3;c=3;break;
        case 8:a=2;b=2;c=4;break;
        case 9:a=2;b=3;c=4;break;
        case 10:a=2;b=3;c=5;break;
        case 11:a=2;b=4;c=5;break;
        case 12:a=3;b=4;c=5;break;
        default:a=0;b=2;c=0;break;
    }
    if(seq<=a)
    {
        return "A";
    }
    if(seq>a && seq<=(b+a))
    {
        return "B";
    }
    if(seq>b+a && seq<=(c+b+a))
    {
        return "C";
    }
    return "NOTDEF";
}


var index=99999;
for(var i=0;i<obj.length;i++)
{
    index=findMaxIndex(obj);
    if(index!=99999)
    {
        obj[index].seq=i+1;
    }
}


var level="NOTDEF";
for(var i=0;i<obj.length;i++)
{
    level=SeqToLevel(obj[i].seq,obj.length);
    obj[i].level=level;
}
for(var i=0;i<obj.length;i++)
{
    console.log(obj[i].seq+"  "+obj[i].score+"  "+ obj[i].level);
}


console.log('-----------------------------');

var arr=['a','b','c'];
arr.name='tsq';
for(var x in arr)
{
    console.log(x);
}
for(var y of arr)
{
    console.log(y);
}
console.log('-----------------------------');



var path=require('path');
var root=path.resolve('.');
console.log(root);
